
#include<bits/stdc++.h>

using namespace std;

int n, m, x, y;


void dfs(int x, int y, vector<vector<int>> &G, vector<vector<int>> &book, vector<vector<int>> &dir, int &cnt) {
    if (book[x][y] == 1 || G[x][y] == 0)return;
    ++cnt;
    book[x][y] = 1;
    for (int i = 0; i < 4; i++) {
        int nx = x + dir[i][0];
        int ny = y + dir[i][1];
        if (nx < 0 || nx >= n || ny < 0 || ny >= m)continue;
        if (book[nx][ny] || G[nx][ny] == 0)continue;
        dfs(nx, ny, G, book, dir, cnt);
    }
}

int main() {
    //freopen("E.in","r",stdin);
    while (cin >> n >> m >> x >> y) {
        vector<vector<int>> dir = {{0,  1},
                                   {0,  -1},
                                   {1,  0},
                                   {-1, 0}};//四连通
        vector<vector<int>> G(n, vector<int>(m, 0));
        vector<vector<int>> book(n, vector<int>(m, 0));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cin >> G[i][j];
            }
        }
        x--;
        y--;

        int cnt = 0;
        dfs(x, y, G, book, dir, cnt);
        cout << cnt << endl;

    }

    return 0;
}